package com.baidu.foodrecipe.ui.activity


import android.util.Log
import android.widget.Toast
import androidx.activity.viewModels
import com.baidu.foodrecipe.R
import com.baidu.foodrecipe.base.BaseActivity
import com.baidu.foodrecipe.databinding.ActivityMainBinding
import com.baidu.foodrecipe.ui.adapters.MainAdapter
import com.baidu.foodrecipe.ui.fragment.favorite.FavoriteViewModel
import com.baidu.foodrecipe.ui.fragment.recipes.MainViewModel
import com.google.android.material.tabs.TabLayoutMediator


class MainActivity : BaseActivity<ActivityMainBinding>() {
    private val favoriteViewModel: FavoriteViewModel by viewModels()

    override fun initUI() {
        favoriteViewModel.loadFavorites()

        //配置ViewPager不能手动滚动
        mBinding.viewPager.isUserInputEnabled = false
        mBinding.viewPager.adapter = MainAdapter(this)

        TabLayoutMediator(mBinding.tabLayout,mBinding.viewPager){ tab, position ->
            when(position){
                0 -> {
                    tab.setIcon(R.drawable.ic_recipe)
                    tab.setText("食谱")
                    tab.view
                }
                1 -> {
                    tab.setIcon(R.drawable.ic_favorite)
                    tab.setText("收藏")
                }
                2 -> {
                    tab.setIcon(R.drawable.ic_face)
                    tab.setText("谚语")
                }
            }
        }.attach()
    }
}












